﻿@model FantasyDraft2.Models.SinglePlayerViewModel

@{
    ViewBag.Title = "ViewHistory";
}

<h2>History for @Model.playername</h2>

@using (Html.BeginForm())
{
    if (Model.events.Count() == 0)
    {
    <div>
        No events found for player!
    </div>
    }
    else
    {
    
    <table>
        <tr>
            <th>Date
            </th>
            <th>Event Type
            </th>
            <th>Initial Team
            </th>
            <th>Final Team
            </th>
        </tr>
        @foreach (FantasyDraft2.Models.PlayerEvent pevent in Model.events)
        {
            <tr>
                <td>
                    @pevent.EventDate
                </td>
                @if (@pevent.EventType == 1)
                {
                    <td>Trade</td>
                }
                else if (@pevent.EventType == 2)
                {
                    <td>Injury</td>
                }
                else if (@pevent.EventType == 3)
                {
                    <td>Draft</td>
                }
                else
                {
                    <td>Cut</td>
                }
                <td>
                    @Model.teamnames.SingleOrDefault(x => x.Key == @pevent.InitialTeamId).Value
                </td>
                <td>
                    @Model.teamnames.SingleOrDefault(x => x.Key == @pevent.FinalTeamId).Value
                </td>
            </tr>
        }
    </table>
    }
    <h2>Comments</h2>
    if (@Model.comments.Count() > 0)
    {
    <table>
        @foreach (FantasyDraft2.Models.PlayerComment comment in Model.comments)
        {
            <tr>
                <td>
                    @comment.Comment
                </td>
            </tr>   
        }
    </table>
    }
    else
    {
    <div>No comments found!</div>   
    }
    <table>
        <tr>
            <td>
                <input type="submit" name="button" value="Add Comment" />
            </td>
            <td>
                <input type="submit" name="button" value="Go back" />
            </td>
        </tr>
    </table>
    @Html.HiddenFor(x => Model.playerId)
}